import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import Components from 'unplugin-vue-components/vite'
import { NaiveUiResolver } from 'unplugin-vue-components/resolvers'
import topLevelAwait from 'vite-plugin-top-level-await'
import { resolve } from 'path' 
import AutoImport from 'unplugin-auto-import/vite'
// const pathResolve = (dir: string): any => {  
//   return resolve(__dirname, ".", dir)          
// }
// const alias: Record<string, string> = {
//   '@': pathResolve("src")
// }
export default defineConfig({
  base: "./assets",
  server: {
    host: '0.0.0.0',
    port: 8080,
    // proxy:{
    //   '/api':{
    //     target:'http://192.168.1.176:3000'
    //   }
    // }
    open: 'index.html' , //热更新视图
  },
  plugins: [
    vue(),
  
  // topLevelAwait({
  //   // The export name of top-level await promise for each chunk module
  //   promiseExportName: '__tla',
  //   // The function to generate import names of top-level await promise in each chunk module
  //   promiseImportName: i => `__tla_${i}`})
  ],
  resolve: {
    alias: {
        "@": resolve(__dirname, "src"),
        // "view": resolve(__dirname, "src/view"),
        // "components": resolve(__dirname, "src/components"),
        // "assets": resolve(__dirname, "src/assets"),
        // "store": resolve(__dirname, "src/store"),
        // "mixins": resolve(__dirname, "src/mixins"),
    },
},
  css:{
    preprocessorOptions: {
       scss: {
         additionalData: `@import "@/style/global.scss";`
       } 
     }
 }      // ****************** 路径配置新增
})
